Skip to content

Conversation

craftyworks
Copy link

Problem

When migrating from KAPT to KSP, inner class naming conventions differ:

  • KAPT: QOuterClass_InnerClass
  • KSP: QInnerClass

This breaks existing code that relies on KAPT naming conventions.

Solution

Modified QueryModelExtractor.queryClassName() to:

  1. Traverse parent class hierarchy using generateSequence
  2. Collect all class names from inner to outer
  3. Join with underscore separator to match KAPT behavior

Changes

  • Fixed: Inner class naming now matches KAPT exactly
  • Added: Comprehensive test coverage for nested scenarios
  • Maintained: Backward compatibility for top-level classes

Test Cases

  • ✅ Single level inner class: OuterClass.InnerClassQOuterClass_InnerClass
  • ✅ Multi-level nesting: A.B.CQA_B_C
  • ✅ Top-level classes unchanged: TopLevelQTopLevel
  • ✅ Custom prefix/suffix support

Breaking Changes

None - this fixes compatibility issues rather than introducing them.

  - Change queryClassName generation to use underscore separator for nested classes
  - Maintains compatibility with existing KAPT-generated Q-classes
  - Add comprehensive test cases for inner class naming scenarios

  Fixes: Inner classes now generate QOuterClass_InnerClass instead of QInnerClass
  This ensures seamless migration from KAPT to KSP without breaking existing code.
Copy link

codecov bot commented Aug 15, 2025

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (a7692cf) to head (a9422dc).
⚠️ Report is 20 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...in/com/querydsl/ksp/codegen/QueryModelExtractor.kt 0.00% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #1317    +/-   ##
=======================================
  Coverage    0.00%   0.00%            
=======================================
  Files         812     837    +25     
  Lines       31149   31484   +335     
  Branches     3536    3545     +9     
=======================================
- Misses      31149   31484   +335     
Flag Coverage Δ
cubrid 0.00% <0.00%> (?)
db2 0.00% <0.00%> (?)
embedded 0.00% <0.00%> (?)
examples 0.00% <ø> (?)
firebird 0.00% <0.00%> (?)
mongodb 0.00% <0.00%> (?)
mysql 0.00% <0.00%> (?)
oracle 0.00% <0.00%> (?)
postgresql 0.00% <0.00%> (?)
test 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@velo velo requested a review from IceBlizz6 September 5, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant